<?php

namespace App\Jobs;

use App\Services\GrabService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;

class SettlementShippingJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    public $data;

    /**
     * SettlementShippingJob constructor.
     */
    public function __construct($data)
    {
        $this->data = $data;
    }


    /**
     * 2021/3/22--3:16 下午
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @effect:处理订单自动收货
     */
    public function handle()
    {
        try {
            DB::beginTransaction();
            $service = new GrabService();
            $ids = explode(',',$this->data['order_id']);
            $service->changeStatus($ids, 3);
            DB::commit();
        }catch (\Exception $e) {
            DB::rollBack();
            $this->release(5);
        }
    }
}
